package com.qingke.easyjava.hibernate.bean;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

@Table(name="student")
@Entity
@Cache(usage=CacheConcurrencyStrategy.READ_ONLY)
public class Student {
	@Id
	@Column(name="id")
	private int id;
	
	@Column(name="sid")
	private int sid;
	
	@Column(name="firstname")
	private String firstname;
	
	@Column(name="lastname")
	private String lastname;
	
	@Column(name="gender")
	private String gender;
	
	@Column(name="email")
	private String email;
	
	@Column(name="age")
	private int age;
//	@Column(name="student_status_id")
//	private int studentStatusId;
	
	@ManyToOne
	@JoinColumn(name="student_status_id")
	private StudentStatus status;
	
	@OneToMany
	@JoinColumn(name="student_id")
	private Set<Accommodation> accommodations;
	
	@OneToOne
	@PrimaryKeyJoinColumn
	private StudentLogin login;

	
	public StudentStatus getStatus() {
		return status;
	}
	public void setStatus(StudentStatus status) {
		this.status = status;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public int getSid() {
		return sid;
	}
	public void setSid(int sid) {
		this.sid = sid;
	}
	public String getFirstname() {
		return firstname;
	}
	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}
	public String getLastname() {
		return lastname;
	}
	public void setLastname(String lastname) {
		this.lastname = lastname;
	}
	public String getGender() {
		return gender;
	}
	public void setGender(String gender) {
		this.gender = gender;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	
	
	public StudentLogin getLogin() {
		return login;
	}
	public void setLogin(StudentLogin login) {
		this.login = login;
	}
	
	public Set<Accommodation> getAccommodations() {
		return accommodations;
	}
	public void setAccommodations(Set<Accommodation> accommodations) {
		this.accommodations = accommodations;
	}
	
	@Override
	public String toString() {
		return "[id=" + id + ", sid=" + sid + ", firstname=" + firstname + ", lastname=" + lastname
				+ ", gender=" + gender + ", email=" + email + ", age=" + age 
				+ "]";
	}
	

	
	
}
